#include "servercontrol.h"
#include "netmain.h"
#include "sqlmain.h"
ServerControl * ServerControl::obj = nullptr;

ServerControl::ServerControl(QObject *parent)
    : QObject{parent}
{

}

ServerControl *ServerControl::getObject()
{
    if(obj == nullptr)
        obj = new ServerControl;
    return obj;
}

void ServerControl::serverInit()
{
    SqlMain::getObject();
    NetMain::getObject();
}

bool ServerControl::serverStart()
{
    bool ok;
    ok = NetMain::getObject()->netStart();
    if(!ok)
    {
        errorInfo = NetMain::getObject()->netGetLastErrorInfo();
    }
    return ok;
}

QString ServerControl::serverGetLastErrorInfo()
{
    return errorInfo;
}
